package cn.ivbao.project.student;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.json.JSONArray;
import cn.ivbao.actions.BaseAction;
import com.opensymphony.xwork2.Action;
public class StudentAction extends BaseAction {

private static final Log log = LogFactory.getLog(StudentAction.class);

private Student student = new Student();

public Student getStudent() {
	return student;
}
public void setStudent(Student student) {
	this.student = student;
}
public String select() {
	cn.ivbao.project.student.StudentDao td = (cn.ivbao.project.student.StudentDao) this.getBean("studentDao");
	List lt = td.select(student);
	for(int i=0;i<lt.size();i++){
		student = (Student)lt.get(i);
	}
	JSONArray json = JSONArray.fromObject(lt);//List生成JSON对象
	toInStream(json.toString());//将生成的JSON对象转成InputStream
	log.debug(json.toString());
	return Action.SUCCESS;
}
public String add() {
	cn.ivbao.project.student.StudentDao td = (cn.ivbao.project.student.StudentDao) this.getBean("studentDao");
	Object lt = td.add(student);
	JSONArray json = JSONArray.fromObject(lt);//List生成JSON对象
	toInStream(json.toString());//将生成的JSON对象转成InputStream
	log.debug(json.toString());
	return Action.SUCCESS;
}

}